@extends('layout.admin')

@section('title')
    <title>管理员列表</title>
@endsection
 
@section('css')

@endsection

@section('content')
<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">修改管理员信息
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
    	<form class="am-form update" action="{{url('admin/Users')}}" method="post">
			{{ csrf_field() }}
			{{ method_field('put') }}
			<fieldset>
			    <div class="am-form-group am-text-left">
					<label for="doc-ipt-email-1">用户名</label>
					<input type="text" class="" name="name">
				</div>

			    <div class="am-form-group am-text-left">
					<label for="doc-ipt-email-1">密码</label>
					<input type="password" class="" name="password">
				</div>

				<div class="am-form-group am-text-left">
					<label for="doc-ipt-pwd-1">确认密码</label>
					<input type="password" class="" name="repassword">
				</div>

			    <div class="am-form-group am-text-left">
					<label for="doc-ipt-email-1">邮箱</label>
					<input type="email" class="" name="email">
				</div>
				<div class="am-form-group checkboxs am-text-left">
					@foreach($RoleAll as $role)
						<input type="checkbox" name="roles[]" value="{{ $role->id }}" />{{ $role->display_name or $role->name }}
					@endforeach
				</div>
				<p><button type="submit" class="am-btn am-btn-primary am-btn-block">修改</button></p>
			</fieldset>
		</form>
    </div>
  </div>
</div>

<div class=" admin-content">
    <div class="daohang"></div>
    <div class=" admin-biaogelist" style="background: #fff;">
    	<div class="am-u-lg-12" style="margin-top:10px;">
    		<div class="am-u-lg-3" style="padding: 0px;">
				<section class="am-panel am-panel-default" style="padding: 0px;">
					<header class="am-panel-hd">
						<i class=" am-icon-plus-square" aria-hidden="true"></i>
						<h3 class="am-panel-title" style="display: inline-block;">添加用户</h3>
					</header>
					<div class="am-panel-bd">
						<form class="am-form add" action="{{url('admin/Users')}}" method="post">
							{{ csrf_field() }}
							<fieldset>
							    <div class="am-form-group">
									<label for="doc-ipt-email-1">用户名</label>
									<span style="color: red; font-size: 12px; text-indent: 10px;">请输入用户名</></span>
									<input type="text" class="" name="name">
								</div>

							    <div class="am-form-group">
									<label for="doc-ipt-email-1">密码</label>
									<span style="color: red; font-size: 12px; text-indent: 10px;">请输入密码</></span>
									<input type="password" class="" name="password">
								</div>

							    <div class="am-form-group">
									<label for="doc-ipt-email-1">确认密码</label>
									<span style="color: red; font-size: 12px; text-indent: 10px;">请确认密码</></span>
									<input type="password" class="" name="repassword">
								</div>

							    <div class="am-form-group">
									<label for="doc-ipt-email-1">邮箱</label>
									<span style="color: red; font-size: 12px; text-indent: 10px;">请输入邮箱</></span>
									<input type="email" class="" name="email" id="doc-ipt-email-1">
								</div>

								<div class="am-form-group checkboxes">
									@foreach($RoleAll as $role)
										<input type="checkbox" name="roles[]" value="{{ $role->id }}" />{{ $role->display_name or $role->name }}
									@endforeach
								</div>

								<p><button type="submit" class="am-btn am-btn-primary am-btn-block">添加</button></p>
  							</fieldset>
						</form>
					</div>
				</section>
			</div>
		
			<div class="am-fl am-u-lg-9 list">
					@foreach ($users as $user)
						<section class="am-panel  {{ $user->hasRole('admin') ? 'am-panel-success':'am-panel-default' }} am-u-lg-3 roled" style="padding: 0px; float: left; margin-left: 10px;">
							<header class="am-panel-hd">
								<h3 class="am-panel-title">
									<i class=" am-icon-user-secret" aria-hidden="true"></i>
									{{ $user->name }}
									@if( $user->name != 'itlzk' )
										<form action="{{url('admin/Users/'.$user->id)}}" method="post" class="am-inline-block-display am-fr del">
											{{ csrf_field() }}
											{{ method_field('DELETE') }}
											<button style="border:0px; vertical-align: top; margin-top:1px; position: relative; left: 2px; background-color: rgba(255,255,255,0)" class="am-inline-block" aria-hidden="true"><i class=" am-icon-close" aria-hidden="true"></i></button>
											
										</form>
										<a href="javascript:;" data-user-list="{{$user->id}}"  data-am-modal="{target: '#doc-modal-1'}" class="am-fr updateUrl"><i class=" am-icon-cog" aria-hidden="true"></i></a>
									@endif
								</h3>
							</header>
							<div class="am-panel-bd perms am-text-center" style="font-size: 12px;">
								<i class="am-icon-envelope-o">{{ $user->email }}</i>
								
								<table class="am-table-centered am-u-lg-12 am-text-center">
									<thead>
										<tr>
											<th class=" am-text-center">角色</th>
											<th class=" am-text-center">权限</th>
										</tr>
									</thead>
									<tbody>
										@foreach($user->roles as $role)
										<tr style="border-top: 1px solid #ccc;">
											<td style="border-right: 1px solid #ccc;" class="{{ $role->name == 'admin' ? 'am-text-danger':'am-text-secondary' }}">
												{{ $role->display_name or $role->name }}
											</td>
											<td>
												<ul class="am-list" style="margin:10px auto;">
													@foreach($role->perms as $perm)
														<li style="border: 0px;"><i class=" am-icon-tags" data-perm-id="{{ $perm->id }}" aria-hidden="true"></i> {{ $perm->display_name or $perm->name }} </li>
													@endforeach
												</ul>
											</td>
										</tr>
										@endforeach
									</tbody>
								</table>
								
							</div>
						</section>
					@endforeach
			</div>
		</div>
		@include('common.footer')
	</div>
</div>
@endsection

@section('js')
	<script type="text/javascript" src="{{asset('common/IsExistsData.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/users.js')}}"></script>
    <script type="text/javascript">

    </script>
@endsection

@section('prompt')
 <div class="waring" style="width: 100px; height: 100px; position: absolute; z-index: 2; top:80px; left: 600px;">
	@if(session('waring'))
		<p> {{ session('waring') }} </p>
	@endif
 </div>
@endsection
